﻿@model CREAPA.Dominio.Portaria

@{
    ViewBag.Title = "Cadastrar";
}
<script src="~/Scripts/js/JavaScriptUtil.js"></script>
<script src="~/Scripts/js/Parsers.js"></script>
<script src="~/Scripts/js/original/InputMask.js"></script>

<script language="javascript">
    function setup() {
        var errorMessage = "Data Invalida: ${value}. Formato Esperado: ${mask}";
        var DataPortaria = new DateMask("dd/MM/yyyy", "DataPortaria");
        DataPortaria.validationMessage = errorMessage;

    }
</script>

<script>
    $(function () {
        $('#Descricao').ckeditor();
    });

</script>
<style>
    .flutua {
        display: inline-block;
        margin-right: 3em;
    }

    #DataPortaria {
    width: 96px;
    height: 10px;
    }
</style>

<h2>Cadastrar</h2>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

@Html.AntiForgeryToken()
<body onload="setup()">
    <fieldset>
        <legend>Portaria</legend>
        <div class="flutua">
            <div class="editor-label">
                @Html.LabelFor(model => model.IdTipoPortaria)
            </div>
            <div class="editor-field">
                <div class="login-msg">
                    @Html.DropDownList("IdTipoPortaria",  "Selecione") 
            @Html.ValidationMessageFor(model => model.IdTipoPortaria)
                </div>
            </div>
        </div>
        <div class="flutua">
            <div class="editor-label">
                @Html.LabelFor(model => model.IdAssuntoPortaria)
            </div>
            <div class="editor-field">
                <div class="login-msg">
                    @Html.DropDownList("IdAssuntoPortaria",  "Selecione") 
            @Html.ValidationMessageFor(model => model.IdAssuntoPortaria)
                </div>
            </div>
        </div>
        <br />
        <br />
        <div class="editor-label">
            @Html.LabelFor(model => model.Descricao)
        </div>
        <div class="editor-field">
            <div class="login-msg">
                @Html.TextAreaFor(model => model.Descricao)
                        @Html.ValidationMessageFor(model => model.Descricao)
            </div>
            <br />
            <div class="editor-label">
                @Html.LabelFor(model => model.DataPortaria)
            </div>
            <div class="editor-field">
                <div class="login-msg">
                    @Html.EditorFor(model => model.DataPortaria)
                        @Html.ValidationMessageFor(model => model.DataPortaria)
                </div>

                <p>
                    <input type="submit" value="Cadastrar" class="button" />
                    @Html.ActionLink("Voltar", "Index",null,new { @class = "button2" })
                </p>
    </fieldset>
</body>
}


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
<script>
    jQuery(document).ready(function () {
        // verifica se existe algum elemento com a class
        if ($(".button").length) {
            // adiciona evento desabilitando o botão
            $(".button").on('click', function () {
                $(this).attr({
                    disabled: true
                });
                // descobrindo o form pai e enviando
                this.value = 'Enviando...';
                $(this).parents('form:first').submit();
            });
        }
    });
</script>